﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SportsStore.Domain.Abstract;

namespace SportsStore.WebUI.Controllers
{
    public class NavController : Controller
    {
        private IProductRepository repo;

        public NavController(IProductRepository repository)
        {
            repo = repository;
        }

        public PartialViewResult Menu(string category = null)
        {
            ViewBag.SelectedCategory = category;
            IEnumerable<string> categories = repo.Products
                .Select(c => c.Category)
                .Distinct()
                .OrderBy(c => c);

            return PartialView(categories);
        }

    }
}
